home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Online / News / Thor / HD-Install / thor.lha / rexx / BBSRead / ForwardMsg.br < prev    next >
Text File  |  1997-08-29  |  3KB  |  127 lines

  1. /*
  2. ** $VER: ForwardMsg.thor 1.0 (13.5.97)
  3. ** by Eirik Nicolai Synnes
  4. **
  5. */
  6.  
  7. options results
  8. options failat 31
  9.  
  10. parse arg arguments
  11.  
  12. template = 'SYSTEM/A,CONFERENCE/A,MSGNO/A/N,TO/A'
  13.  
  14.  
  15. /*
  16. ** INITIALIZATION
  17. */
  18.  
  19. EVE_ENTERMSG      =  0        /* Enter message */
  20. EVE_REPLYMSG      =  1        /* Reply message */
  21. EVE_FORWARDMSG    =  9        /* Forward message (only TCP/SOUP) */
  22.  
  23. MDB_URGENT        = 11        /* Message is urgent.    */
  24. MDB_RETURNRECEIPT = 26
  25. MDB_ENCODE8BIT    = 27
  26.  
  27.  
  28. /*
  29. ** Check if BBSREAD's ARexx port is open, open it if it's not
  30. */
  31.  
  32. if ~(show('P', 'BBSREAD')) then do
  33.     address(command)
  34.     'Run >NIL: `GetEnv THOR/THORPath`bin/LoadBBSRead'
  35.     if exists('SYS:RexxC/WaitForPort') then 'SYS:RexxC/WaitForPort BBSREAD'
  36.     else 'WaitForPort BBSREAD'
  37.     if (rc = 5) then do; say 'Could not open BBSREAD''s ARexx port.'; exit(30); end
  38.     if (rc ~= 0) then do; say 'Could not find SYS:Rexxc/WaitForPort.'; exit(30); end
  39.     end
  40.  
  41.  
  42. /*
  43. ** Parse command line
  44. */
  45.  
  46. if (arguments = '') | (arguments = '?') then do
  47.     say 'Template: 'template
  48.     say 'BounceMsg.br is an external script for SortMail.'
  49.     exit(20)
  50.     end
  51.  
  52. address(bbsread)
  53. 'READARGS 'template args' CMDLINE 'arguments
  54. if (rc ~= 0) then do
  55.     say 'Template: 'template
  56.     say 'READARGS failed: 'BBSREAD.LASTERROR
  57.     exit(rc)
  58.     end
  59.  
  60.  
  61. /*
  62. ** Get message data
  63. */
  64.  
  65. 'READBRMESSAGE "'args.SYSTEM'" "'args.CONFERENCE'" 'args.MSGNO' DATASTEM 'msgdata' HEADSTEM 'msghead
  66. if (rc ~= 0) then do
  67.     say 'READBRMESSAGE, data & head stem: 'BBSREAD.LASTERROR
  68.     exit(rc)
  69.     end
  70.  
  71.  
  72. /*
  73. ** Get addresses to mail message to and create event data
  74. */
  75.  
  76. if (index(args.TO, '@') > 0) then do
  77.     eventdata.TONAME = ''
  78.     eventdata.TOADDR = args.TO
  79.     end
  80. else do
  81.     'SEARCHBRUSER "'args.SYSTEM'" STEM 'user' SEARCH "'args.TO'" NAME'
  82.     if (rc ~= 0) then do
  83.         say 'SEARCHBRUSER: 'BBSREAD.LASTERROR
  84.         exit(rc)
  85.         end
  86.  
  87.     if (result = 0) then do
  88.         say 'No user with the name "'args.TO'".'
  89.         exit(20)
  90.         end
  91.  
  92.     'READBRUSER BBSNAME "'args.SYSTEM'" USERNR 'user.1.USERNR' TAGSSTEM 'usertags' DATASTEM 'userdata
  93.     if (rc ~= 0) then do
  94.         say 'READBRUSER: 'BBSREAD.LASTERROR
  95.         exit(rc)
  96.         end
  97.  
  98.     if (symbol('usertags.ADDRESS') ~= 'VAR') | (strip(usertags.ADDRESS, 'B') = '') then do
  99.         say 'User "'args.TO'" does not have any addresses defined.'
  100.         exit(20)
  101.         end
  102.  
  103.     eventdata.TONAME = usertags.NAME
  104.     eventdata.TOADDR = usertags.ADDRESS
  105.     end
  106.  
  107.  
  108. eventdata.SUBJECT       = msghead.SUBJECT || ' (fwd)'
  109. eventdata.CONFERENCE    = 'EMail'
  110. eventdata.REFCONFERENCE = args.CONFERENCE
  111. eventdata.REFNR         = args.MSGNO
  112.  
  113. if (symbol('msghead.MSGID') = 'VAR') then eventdata.REFID = msghead.MSGID
  114.  
  115.  
  116. /*
  117. ** Write the new event
  118. */
  119.  
  120. 'WRITEBREVENT BBSNAME "'args.SYSTEM'" EVENT 'EVE_FORWARDMSG' STEM 'eventdata
  121. if (rc ~= 0) then do
  122.     say 'WRITEBREVENT: 'BBSREAD.LASTERROR
  123.     exit(rc)
  124.     end
  125.  
  126. exit(0)
  127.